<template>
  <div id="building" style="margin-right: 100px;">
    <div style="display: flex; justify-content: center; ">
      同学请把文件按自己姓名加学号加压上传(夏志豪-201910803077)
    </div>
    <div class="file">
      <el-upload
        class="upload-demo"
        drag
        :action="'http://'+ serverIp +':8081/file/studentUpload'"
        :auto-upload="false"
        ref="upload"
        :data="username"
        multiple
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
          只能上传zip/tar文件，且不超过500kb
        </div>
      </el-upload>
    </div >
    <div style="   display: flex; justify-content: center; width: 500px;
    margin-left: 30%;  margin-top: 30px;">个人评价</div>
      <div class="text">
       <el-input
  style=" font-size: 15px;font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;"
   type="textarea"
  :rows="10"
   placeholder="请输入内容"
  v-model="textarea">
</el-input>
    </div>
    <div  style="   display: flex; justify-content: center; width: 500px;
    margin-left: 544px;  margin-top: 10px;"><el-button type="success" @click="submit">提交</el-button><el-button type="info" @click="reset">重置</el-button></div>
  </div>
  
</template>
<script>
import { serverIp } from '@/utils/config';
import request from '@/utils/request';
export default {
    data(){
        return{
            serverIp:serverIp,
            textarea:'',
            name:JSON.parse(localStorage.getItem("user")).username,
            username:{
                username:JSON.parse(localStorage.getItem("user")).username,
            },
            user:{"username":JSON.parse(localStorage.getItem("user")).username,"selfEvaluation":""}
        }
    },
    methods:{
       reset(){
         this.textarea=''
       },
        submit(){ 
            this.$refs.upload.submit();
            this.user.selfEvaluation=this.textarea;
            request.post("/user/saveEvaluation",this.user,{params:{name:this.name}}).then(res=>{
              if(res.status==200){
                this.$message.success("个人评价更新成功,请等待教师成绩评定")
              }
              else{
                this.$message.error(res.msg)
              }
            })
        }
    }

};
</script>
<style scoped>
.file {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}
.text{
    display: flex; justify-content: center; width: 500px;
    margin-left: 30%;
    margin-top: 10px;
    
}
</style>